import Vue from 'vue'
import Vuex from 'vuex'

//挂载Vuex
Vue.use(Vuex)
const store = new Vuex.Store({
    state: {
        //存放的键值对就是所要管理的状态
        city: localStorage.getItem("cityName") || '北京'
    },
    mutations: {
        changeCity(state, cityName) {
            state.city = cityName
            localStorage.setItem('cityName', cityName)
        }

    }
})

export default store